package com.sherllinhe.member.controller.feign;

import com.sherllinhe.common.req.MemberTicketReq;
import com.sherllinhe.common.resp.CommonResp;
import com.sherllinhe.common.resp.PageResp;
import com.sherllinhe.member.req.TicketQueryReq;
import com.sherllinhe.member.resp.TicketQueryResp;
import com.sherllinhe.member.service.TicketService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 功能：
 * 作者：Sherllin He
 * 日期：
 */
@RequestMapping("/admin/feign/ticket")
@RestController
public class FeignTicketController {
    @Autowired
    private TicketService ticketService;

    @PostMapping("/save")
    public CommonResp<Object> register(@Valid @RequestBody MemberTicketReq req) throws Exception {
        ticketService.save(req);
        return new CommonResp<>();
    }

    @GetMapping("/query-list")
    public CommonResp<PageResp<TicketQueryResp>> register(@Valid TicketQueryReq req){
        PageResp<TicketQueryResp> list = ticketService.queryList(req);
        return new CommonResp<>(list);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id){
        ticketService.delete(id);
        return new CommonResp<>();
    }
}
